import request from './request';

// 获取所有记录
export const getChatList = (params) => {
  return request({
    url: '/chatutils/chatutils/details',
    method: 'get',
    params
  });
}

// 获取聊天历史记录
export function getChatHistory(userId1, userId2) {
  return request({
    url: '/chatutils/chatutils/history',
    method: 'get',
    params: {
      userId1,
      userId2
    }
  });
}

// 标记消息为已读
export function markMessagesAsRead(senderId, receiverId) {
  return request({
    url: '/chatutils/chatutils/read',
    method: 'put',
    params: {
      senderId,
      receiverId
    }
  });
}

// 获取未读消息数量
export function getUnreadCount(userId) {
  return request({
    url: '/chatutils/chatutils/unread/count',
    method: 'get',
    params: {
      userId
    }
  });
}

// 发送聊天消息
export function sendChatMessage(message) {
  return request({
    url: '/chatutils/chatutils',
    method: 'post',
    data: message
  });
}